package com.zhidisoft.admin.service.impl;

import java.math.BigInteger;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zhidisoft.admin.aonn.ServiceLogAnno;
import com.zhidisoft.admin.entity.ArticleType;
import com.zhidisoft.admin.mapper.IArticleTypeMapper;
import com.zhidisoft.admin.service.IArticleTypeService;
import com.zhidisoft.admin.vo.PageVo;

@Service
@Transactional
public class ArticleTypeServiceImpl implements IArticleTypeService {

	@Autowired
	IArticleTypeMapper mapper;
	/**
	 * 点击保存(添加分类)
	 * @return
	 */
	@Override
	@ServiceLogAnno("文章类型-添加类型")
	public void save(ArticleType articleType) {
		mapper.save(articleType);
	}
	
	/**
	 * 删除页面
	 * @return
	 */
	@Override
	@ServiceLogAnno("文章类型-删除类型")
	public void delete(String typeId){
		mapper.deleteById(typeId);
	}
	
	/**
	 * 进入修改页面
	 * @return
	 */
	@Override
	public ArticleType getById(String typeId) {
		return mapper.findById(typeId);
	}
	
	/**
	 * 点击修改
	 * @return
	 */
	@Override
	@ServiceLogAnno("文章类型-修改类型")
	public void update(ArticleType articleType) {
		mapper.update(articleType);
	}
	
	/**
	 * 查询所有数据
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	@Override
	@ServiceLogAnno("文章类型-展示所有类型")
	public List<ArticleType> pageList(Integer pageNum, Integer pageSize) {
		return mapper.pageList(pageNum, pageSize);
	}
	
	/**
	 * 获取总条数
	 * @return
	 */
	@Override
	@ServiceLogAnno("文章类型-添加")
	public BigInteger totalCount() {
		return mapper.totalCount();
	}
	
	@Override
	@ServiceLogAnno("文章类型-添加")
	public List<ArticleType> geArticleTypes() {
		return mapper.getArticleTypes();
	}

	@Override
	public PageVo findPage(Integer pageNum, Integer pageSize) {
		PageVo pageVo = new PageVo();
		pageVo.setPageNum(pageNum);
		pageVo.setPageSize(pageSize);
		pageVo.setList(mapper.pageList((pageNum-1)*pageSize, pageSize));
		pageVo.setTotalCount(mapper.totalCount().intValue());
		return pageVo;
	}

}
